package ru.caporegim.spring;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ru.caporegim.service.CalculatorFacade;
import ru.caporegim.service.calc.Calculator;
import ru.caporegim.service.calc.SimpleCalculator;

/**
 * Created by IntelliJ IDEA.
 * User: senior
 * Date: 06.10.12
 * Time: 21:50
 * To change this template use File | Settings | File Templates.
 */
public class Starter2 {
    public static void main(String[] args) {
        ApplicationContext context =
                new ClassPathXmlApplicationContext("Spring-Config-2.xml");
        BeanFactory factory = (BeanFactory) context;
        SimpleCalculator calc = factory.getBean("simpleCalculator", SimpleCalculator.class);
        long res = calc.sum(1,3);
        System.out.println("res = " + res);

        Calculator calc2 =(Calculator) factory.getBean("simpleCalculator");
        res = calc.sum(1,3);
        System.out.println("res = " + res);

        CalculatorFacade facade = (CalculatorFacade) factory.getBean("calcFacade");
        System.out.println(facade.sum(0,1));


    }
}
